package com.laoma.stockcenter.dao.mapper;

import com.laoma.ordercenter.common.mapper.BaseMapper;
import com.laoma.stockcenter.dao.entity.StockInfo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface StockInfoMapper extends BaseMapper<StockInfo> {

    /**
    * @apiNote 通过产品id查询库存信息
    * @param productId:产品id
    * @return com.laoma.stockcenter.dao.entity.StockInfo
    * @author 老马
    * @date 2022/1/24 16:32
    */
    @Select("select * from stock_info t where t.product_id=#{productId}")
    StockInfo selectByProductId(@Param("productId")String productId);

    /**
    * @apiNote 库存数量-1
    * @param productId:产品id
    * @return void
    * @author 老马
    * @date 2022/1/24 16:25
    */
    @Update("update stock_info set count=count-1 where product_id=#{productId}")
    void reductCountByProductId(@Param("productId") String productId);
}